﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CreateRoomSameNiuPage : EventManager
{
    public override void InformationSetting()
    {
        SameNiu = "1";

        AddListenerToButton(confirmBtn, ConfirmBtnClick);
        AddListenerToButton(cancelBtn, CancelBtnClick);

        TimeSliderSelect(0);
    }

    public Button confirmBtn;
    public Button cancelBtn;
    public Slider SameNiuSlider;
    public GameObject numGroup;

    private string SameNiu;
    public void PlayerCountSliderValueChange()
    {
        int temp = Mathf.FloorToInt(SameNiuSlider.value / 1f);
        SameNiuSlider.value = temp * 1f;
        GetSameNiu(temp.ToString());
        TimeSliderSelect(temp);
    }

    private void TimeSliderSelect(int num)
    {
        for (int i = 0; i < 2; i++)
        {
            if (i == num)
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        for (int i = 2; i < 4; i++)
        {
            if (i == num+2)
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(false);
            }
            else
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(true);
            }
        }
    }

    private void GetSameNiu(string str)
    {
        switch (str)
        {
            case "0":
                SameNiu = "1";
                break;
            case "1":
                SameNiu = "2";
                break;
        }
    }

    public void ConfirmBtnClick()
    {
        CreateRoomController.GetInstance().SameNiu = SameNiu;
     
        CloseBtnClick();
    }

    public void CancelBtnClick()
    {
        CreateRoomPage.GetInstance().SetToggleIsOff(4);
        CloseBtnClick();
    }
}
